package com.pet.cloud.order.api.controller;


import com.pet.cloud.order.api.handler.OrderHandler;
import com.pet.cloud.order.api.param.OrderCreateParam;
import com.pet.cloud.order.api.queryHandler.OrderQueryHandler;
import com.pet.cloud.order.api.view.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderHandler orderHandler;

    @Resource
    private OrderQueryHandler orderQueryHandler;

    @PostMapping(value = "/create")
    public void createOrder(@Valid @RequestBody OrderCreateParam param) {
        orderHandler.create(param);
    }

    @GetMapping(value = "/getOrderInfo")
    private OrderInfo getOrderInfo(String orderNo) {
        return orderQueryHandler.getOrderInfo(orderNo);
    }
}
